package com.rundow.common.sdk.bean.driver;

import cn.hutool.core.util.ObjectUtil;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.concurrent.ConcurrentHashMap;

/**
 * 驱动容器上下文
 */
@Component
public class ContainerContext extends ConcurrentHashMap<String, DriverContext> {


    public DriverContext factoryDriverContext(String driverName) {

        DriverContext driverContext = this.get(driverName);
        if (ObjectUtil.isNull(driverContext)) {
            driverContext = new DriverContext();
            super.put(driverName, driverContext);
            return driverContext;
        }
        return driverContext;
    }
}
